import java.util.Calendar;
import java.util.Date;

public class Calendar2 {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        System.out.println(c.get(1));
        System.out.println(c.get(Calendar.YEAR));
        //输出年份
        System.out.println(c.get(2) + 1);
        System.out.println(c.get(Calendar.MONTH) + 1);
        //输出月份
        System.out.println(c.get(Calendar.DAY_OF_MONTH));
        //输出日期
        System.out.println(c.get(Calendar.HOUR_OF_DAY));
        //输出小时
        System.out.println(c.get(Calendar.MINUTE));
        //输出分钟
        System.out.println(c.get(Calendar.SECOND));
        //输出秒数
        System.out.println(c.get(Calendar.DAY_OF_WEEK) - 1);
        //输出星期几
        System.out.println("===== 获取方法.get() =====");


        int y = c.get(Calendar.YEAR);
        int m = c.get(Calendar.MONTH) + 1;
        int d = c.get(Calendar.DAY_OF_MONTH);
        int h = c.get(Calendar.HOUR_OF_DAY);
        int i = c.get(Calendar.MINUTE);
        int s = c.get(Calendar.SECOND);
        System.out.printf("%d年%02d月%02d日 %d:%d:%d 星期%s %n", y, m, d, h, i, s, c.get(Calendar.DAY_OF_WEEK) - 1);
        System.out.printf("%d年%02d月%02d日 %d:%d:%d %tA %n", y, m, d, h, i, s, c);



        System.out.println("===== 设置方法.set() =====");
        //格式化输出当前星期几
        System.out.printf("%tA%n",new Date());
        System.out.println("===== 计算2025年4月20日是星期几？ =====");
        //计算2025年4月20日是星期几？
        Calendar w = Calendar.getInstance();
        w.set(Calendar.YEAR,2025);
        w.set(Calendar.MONTH,3);
        w.set(Calendar.DAY_OF_MONTH,20);
        System.out.printf("%tF 这一天是%tA%n",w,w);






    }

}
